
function isRealEmpty(val) {
  return val === null || val === undefined || val === 'null' || val === 'undefined' || val === '';
}

export default {
  data() {
    return {
      share: {
        title: '自定义分享标题',
        imageUrl: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg',
      }
    }
  },
  onLoad(options) {
    /*const userInfo = uni.getStorageSync('userInfo')
    if (!isRealEmpty(userInfo)) {
      if (userInfo.level === 2) {
        uni.hideShareMenu(); // 禁止分享好友
        uni.hideShareTimeline(); // 禁止分享朋友圈
      }
    }*/
  },
  onShareAppMessage(res) { //发送给朋友
    const userInfo = uni.getStorageSync('userInfo')
    let shareData = {
      title: `${userInfo.nickname}邀请您使用IM`,
      desc: 'IM, 欢迎注册使用🥰',
      path: `/pages/index/index?shareUserId=${userInfo.id}`
    }
    return {
      ...shareData
    }
  },
  onShareTimeline(res) {//分享到朋友圈
    const userInfo = uni.getStorageSync('userInfo')
    return {
      title: `${userInfo.nickname}邀请您使用IM`,
      imageUrl: this.share.imageUrl,
      path: `/pages/index/index?shareUserId=${userInfo.id}`
    }
  },
}
